package com.yuandian.business.monitor.controller;

import com.yuandian.api.business_monitor.po.ItSegmentDataParams;
import com.yuandian.api.business_monitor.vo.ItSegmentDetailVo;
import com.yuandian.api.business_monitor.vo.ItSegmentInfoVo;
import com.yuandian.api.business_monitor.vo.MonitorOverviewVo;
import com.yuandian.api.business_monitor.vo.SegmentPositionVo;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.business.monitor.service.IAllItRoadService;
import com.yuandian.utils.PageDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 说明：全系统IT路径图controller
 * @Author yanjun
 * @Date 2020/9/21 9:28
 */
@RestController
@Api(value = "allItRoad", tags = "全系统IT路径图接口")
@RequestMapping("/home/allItRoad")
public class AllItRoadController {

    @Autowired
    private IAllItRoadService allItRoadService;

    /**
     * 查询监控概况
     * @return 监控概况
     */
    @PostMapping("/queryMonitorOverview")
	@ApiOperation(value = "查询监控概况", notes = "查询监控概况")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "dateTime", 			value = "当前日期", 			paramType = "query", 	required = true,    dataType = "String")
	})
    public R queryMonitorOverview(@Validated @RequestBody ItSegmentDataParams params) {
        MonitorOverviewVo moVo = allItRoadService.queryMonitorOverview(params);
        return R.ok(moVo);
    }

    /**
     * 查询网端详情数据
     * @param params It路径图端查询参数对象
     * @return 网端数据
     */
    @PostMapping("/querySegmentData")
	@ApiOperation(value = "查询网端详情数据", notes = "查询网端详情数据")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "dateTime", 			value = "当前日期", 			paramType = "query", 	required = true,    dataType = "String")
	})
    public R querySegmentData(@Validated @RequestBody ItSegmentDataParams params) {
        // 调用服务
        List<ItSegmentDetailVo> list = allItRoadService.querySegmentData(params);
        return R.ok(list);
    }

    /**
     * 修改网端坐标
     * @param segmentPositionVo 网端坐标vo对象
     * @return 通用返回对象
     */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "locationX", 			value = "x轴坐标", 			paramType = "query", 	required = true,    dataType = "Double"),
			@ApiImplicitParam(name = "locationY", 			value = "Y轴坐标", 			paramType = "query", 	required = true,    dataType = "Double"),
			@ApiImplicitParam(name = "segmentId", 			value = "网端id", 			paramType = "query", 	required = true,    dataType = "Integer")
	})
    @PostMapping("/updateSegmentPosition")
	@ApiOperation(value = "修改网端坐标")
    public R updateSegmentPosition(@RequestBody SegmentPositionVo segmentPositionVo) {
        return allItRoadService.updateSegmentPosition(segmentPositionVo);
    }


	/**
	 * 查询网端组件详情列表
	 * @return 通用结果集
	 */
	@PostMapping("/getComponentDetailsDataList")
	@ApiOperation(value = "全系统IT路径图-查询网端组件详情列表", notes = "全系统IT路径图-查询网端组件详情列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId",  			value = "系统id",  			paramType = "query", 	required = true, 	dataType = "Integer"),
			@ApiImplicitParam(name = "segmentId",  			value = "网端id",  			paramType = "query", 	required = true, 	dataType = "Integer"),
			@ApiImplicitParam(name = "dateTime", 			value = "查询日期", 			paramType = "query", 	required = true, 	dataType = "String"),

			@ApiImplicitParam(name = "pageNum",   			value = "页码", 				paramType = "query", 	required = true, 	dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 			value = "每页大小", 			paramType = "query", 	required = true, 	dataType = "Long"),
			@ApiImplicitParam(name = "orderByColumn", 		value = "排序字段", 			paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "isAsc", 				value = "升降序:ASC / DESC", paramType = "query", 	required = true, 	dataType = "String")
	})
	public R<Object> getComponentDetailsData(@RequestBody ItSegmentDataParams params) {
		PageDataInfo pageDataInfo = allItRoadService.getComponentDetailsData(params);

		return R.ok(pageDataInfo);
	}

	/**
	 * 查询网络详情列表
	 * @return 通用结果集
	 */
	@RequestMapping("/getNetworkDetailsList")
	@ApiOperation(value = "全系统IT路径图-查询网络详情列表", notes = "全系统IT路径图-查询网络详情列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId",  			value = "系统id",  			paramType = "query", 	required = true, 	dataType = "Integer"),
			@ApiImplicitParam(name = "segmentId",  			value = "网端id",  			paramType = "query", 	required = true, 	dataType = "Integer"),
			@ApiImplicitParam(name = "responseIp", 			value = "IP",  				paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "responsePort", 		value = "端口",  			paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "dateTime", 			value = "查询日期", 			paramType = "query", 	required = true, 	dataType = "String"),

			@ApiImplicitParam(name = "pageNum",   			value = "页码", 				paramType = "query", 	required = true, 	dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 			value = "每页大小", 			paramType = "query", 	required = true, 	dataType = "Long"),
			@ApiImplicitParam(name = "orderByColumn", 		value = "排序字段", 			paramType = "query", 	required = true, 	dataType = "String"),
			@ApiImplicitParam(name = "isAsc", 				value = "升降序:ASC / DESC", paramType = "query", 	required = true, 	dataType = "String")
	})
	public R<Object>  getNetworkDetailsList(@RequestBody ItSegmentDataParams params) {
		PageDataInfo page = allItRoadService.getNetworkDetailsList(params);
		return R.ok(page);
	}

}
